#!/usr/bin/perl

sub my_graph
{
my ($startd,$endd,$graph_data_file, $title, $y_units, $dir_path,$min,$max) = @_;

open (SCRIPT,">$graph_data_file.script");

print SCRIPT "
set terminal png
set output \"$dir_path\"
#640x480 default
set size 0.32,0.24
set title \"$title\"
set autoscale xy
set missing '-99.99'
set data style lines
#set xlabel \"Time (MM/DD HH AM/PM EST)\"  
set timefmt \"%m/%d/%Y %H:%M\"
set xdata time
#set ylabel \"$y_units\" 
#set ytics nomirror
#set format x \"%b%d\\n%l%p\"
set format x \"%m/%d\\n%l%p\"
set grid
set key right
set ytics $min,4,$max
set xtics \"$startd\",80000,\"$endd\"

plot '$graph_data_file' using 1:3 t 'Prediction' with lines lt 1, \\
     '$graph_data_file' using 1:4 t 'Observation' with lines lt 3
     
#show grid

quit";
close SCRIPT;

system("gnuplot $graph_data_file.script");
system("rm $graph_data_file.script");
system("rm $graph_data_file");
}

sub my_graph1
{
my ($graph_data_file, $title, $y_units, $dir_path) = @_;

open (SCRIPT,">$graph_data_file.script");

print SCRIPT "
set terminal png
set output \"$dir_path\"
#640x480 default
#set size 0.4,0.27
set title \"$title\" font \"Times-Roman, 12\"
set autoscale xy
set missing '-99.99'
set data style linespoints
#set xlabel \"Time (YYYY-MM EST)\"  
set timefmt \"%y\%m\"
set xdata time
#set ylabel \"$y_units\" 
#set ytics nomirror
#set format x \"%b%d\\n%l%p\"
set format x \"%y%m\"
set grid
set key right

plot '$graph_data_file' using 1:4 t $title with lines lt 3
     
#show grid

quit";
close SCRIPT;

system("gnuplot $graph_data_file.script");
system("rm $graph_data_file.script");
system("rm $graph_data_file");
}



1;
